package com.wyl.common;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2022/12/30 14:25
 */
@Data
@MappedSuperclass
public class BaseModel<T extends BaseModel<?>> extends Model<T> {
    @Id
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(columnDefinition = "bigint comment '主键id'")
    private Long id;
    @Column(columnDefinition = "int(1) comment '是否删除，1是，0否'")
    private Integer deleted;
    @TableField(fill = FieldFill.INSERT)
    @Column(columnDefinition = "bigint comment '创建人用户id'")
    private Long createUserId;

    @TableField(fill = FieldFill.UPDATE)
    @Column(columnDefinition = "bigint comment '更新人用户id'")
    private Long updateUserId;

    @TableField(fill = FieldFill.INSERT)
    @Column(columnDefinition = "datetime(6) comment '创建时间'")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.UPDATE)
    @Column(columnDefinition = "datetime(6) comment '更新时间'")
    private LocalDateTime updateTime;

    @Override
    public Serializable pkVal() {
        return id;
    }
}
